﻿
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>register</title>
    <link rel="stylesheet" type="text/css" href="~/Content/registerCSS.css" />
</head>
<body>
    <div class="res_ZhuChe">
        <div class="Div1"><span class="HuanYingJiaRu">欢迎加入这个大家庭</span></div>
        <div class="ZhuCheGo">
            <input type="text" class="YongHuMing color_Hui" />
            <span class="YongHuMingPanDuan" style="color: red;"></span>
            <input type="text" class="YouXiang color_Hui" />
            <span class="YouXiangPanDuan" style="color: red;"></span>
            <div class="YanZh">
                <input type="text" class="YanZhengMa color_Hui" maxlength="6" />
                <div class="YanZ YanZ_Ben">
                    <span>获取验证码</span>
                </div>
            </div>
            <span class="YanZhengMaPanDuan" style="color: red;"></span>
            <input type="text" class="MiMa1 color_Hui" />
            <input type="text" class="MiMa2 color_Hui" />
            <span class="MiMaPanDuan"></span>
        </div>
        <div class="ZhuChe_But1">
            <span>注&nbsp&nbsp册</span>
        </div>
    </div>
    <div class="ZC_ThiShi">
        <div class="WanBi"><span>注册完毕</span></div>
        <div class="span1"><span>您的账号为 : </span><span class="span2"></span></div>
        <div class="span3"><span>您的邮箱为 : </span><span class="span4"></span></div>
        <div class="span5"><span>邮箱为更改密码的重要道具</span></div>
        <div class="span6"><span>切记不可丢失</span></div>
        <div class="DaoJiShi">
            <span>倒计时 :</span>
            <span>240</span>
        </div>
        <span class="LiJI LJ_DH">立即跳转</span>
    </div>
    <script src="~/Scripts/jquery-3.4.1.js"></script>
    <script src="~/Scripts/registerJS.js"></script>
    <script>
		$(function () {
			//背景
            $("body").css("background-image", "url('@ViewBag.backImage_register')");
			//注册
			$(".ZhuChe_But1").click(function() {
				But_yanZheng();
                $.post("@Url.Action("registerZhuChe", "MyHome")", { Name: $(".YongHuMing").val(), Gmail: $(".YouXiang").val(), YZM: $(".YanZhengMa").val(), Pwd: pwd_1 }, function (data) {
					console.log("注册中");
					if (data.State == 0) {
						ChengGong(data.number, data.gmail);
					}
					if (data.State == 2) {
                        $(".YanZhengMaPanDuan").text(data.Message);
					}
                    if (data.State == 3) {
                        $(".YouXiangPanDuan").text(data.Message);
					}
                    if (data.State == 3) {
                        $(".YouXiangPanDuan").html(data.Message +"<a href='~MyHome/找回密码'><sub>点击这里找回密码</sub></a>");
                    }
				})
			})
			//注册成功
			var ChengGong = function (number,gmail) {
				$(".span2").text(number);
                $(".span4").text(gmail);

                //注册完毕框显示
                $(".ZC_ThiShi").css("z-index", "1");
                var TS_a = 0.1;
                var time_TS = setInterval(function () {
                    $(".ZC_ThiShi").css("opacity", TS_a);
                    TS_a = TS_a + 0.1;
                    if (TS_a >= 1) {
                        time_Kaishi();
                        clearInterval(time_TS);
                    }
                }, 50);
                //跳转倒计时开始
                var time_Kaishi = function () {
                    var Time_DJS = 239;
                    var time_donghua = setInterval(function () {
                        $(".DaoJiShi>span").eq(1).text(Time_DJS);
                        Time_DJS--;
                        //立即跳转
                        $(".LiJI").click(function () {
                            clearInterval(time_donghua);
                            var time_TS1 = setInterval(function () {
                                $(".DaoJiShi>span").eq(1).text(Time_DJS);
                                Time_DJS--;
                                if (Time_DJS < 0) {
                                    location.href = data.skipPage;
                                    clearInterval(time_TS1);
                                }
                            }, 10)
						})

                        if (Time_DJS < 0) {
                            location.href = data.skipPage;
                            clearInterval(time_donghua);
                        }
                    }, 1000);
                }
			}
			//发送验证码
			var FS_PanDuan = true;
			$(".YanZ").click(function() {
				//判断邮箱
				Gmail_PanDUan();
				if ($(".YouXiang").val() != "" && $(".YouXiang").val() != "邮箱") {
					if (FS_PanDuan == true) {
						$.post("@Url.Action("sendmail","MyHome")", { Gmail: $(".YouXiang").val() }, function (data) {

							if (data.State == 1) {
								console.log(data.Message);
								//发送倒计时
                                FS_PanDuan = false;
                                $(".YanZ").css("cursor", "default");
                                var YanZheng_JiShu = 60;
                                var YZM_Time = setInterval(function () {
                                    $(".YanZ>span").text(YanZheng_JiShu);
                                    if (YanZheng_JiShu == 0) {
                                        $(".YanZ").css("cursor", "pointer");
                                        YanZheng_JiShu = 5;
                                        FS_PanDuan = true;
                                        $(".YanZ>span").text("发送验证码");
                                        clearInterval(YZM_Time);
                                    }
                                    YanZheng_JiShu--;
                                }, 1000);
							}
							if (data.State == 0) {
								$(".YouXiangPanDuan").text(data.Message);
							}
							if (data.State == 2) {
                                $(".YouXiangPanDuan").html(data.Message + "<a href='~MyHome/找回密码'><sub>点击这里找回密码</sub></a>");
                            }
						})
					}
				}
			})
			//判断邮箱
			var Gmail_PanDUan = function() {
				if ($(".YouXiang").val() == "邮箱" || $(".YouXiang").val() == "") {
					$(".YouXiangPanDuan").text("请输入邮箱");
					return false;
				}
				var search_str = /^[\w\-\.]+@@[\w\-\.]+(\.\w+)+$/;
				var email_val = $(".YouXiang").val();
				if (!search_str.test(email_val)) {
					$(".YouXiangPanDuan").text("邮箱格式不正确");
					return false;
				} else {
					$(".YouXiangPanDuan").text("");
					return true;
				}
			}
			//密码
			var pwd_1 = "";
			var MiMa_TiShi = "密码                                    长度大于6位数";
			$(".MiMa1").focus(function() {
				$(".MiMaPanDuan").text("");
				if ($(this).val() != "" && $(this).val() != MiMa_TiShi) {
					$(this).val(pwd_1);
				}
			}).blur(function() {
				pwd_1 = $(this).val();
				if ($(this).val() != MiMa_TiShi) {
					MiMa_YanGai(this, pwd_1);
				}
				MiMa_XiangToing();
			})
			//重复密码
			var pwd_2 = "";
			$(".MiMa2").focus(function() {
				$(".MiMaPanDuan").text("");
				if ($(this).val() != "" && $(this).val() != "重复密码") {
					$(this).val(pwd_2);
				}
			}).blur(function() {
				pwd_2 = $(this).val();
				if ($(this).val() != "重复密码") {
					MiMa_YanGai(this, pwd_2);
				}
				MiMa_XiangToing();
			})
			//判断相同
			var MiMa_XiangToing = function() {
				if ($(".MiMa1").val() != "" && $(".MiMa1").val() != MiMa_TiShi && $(".MiMa2").val() != "" && $(".MiMa2").val() !=
					"重复密码") {
					if (pwd_1 != pwd_2) {
						$(".MiMaPanDuan").text("两次密码不相同");
					}
				}
			}
			//掩盖
			var MiMa_YanGai = function(DuiXiang, pwd) {
				var a = "";
				for (var i = 0; i < pwd.length; i++) {
					a = a + "*";
				}
				$(DuiXiang).val(a);
				if (pwd.length < 6) {
					$(".MiMaPanDuan").text("密码至少6位数");
				}
			}
			//验证
			var But_yanZheng = function() {
				if ($(".YongHuMing").val() == "" || $(".YongHuMing").val() == "用户名") {
					$(".YongHuMingPanDuan").text("用户名不能为空");
					return false;
				}
				if ($(".YouXiang").val() == "" || $(".YouXiang").val() == "邮箱") {
					$(".YouXiangPanDuan").text("邮箱不能为空");
					return false;
				}
				if ($(".YanZhengMa").val() == "" || $(".YanZhengMa").val() == "验证码") {
					$(".YanZhengMaPanDuan").text("验证码不能为空");
					return false;
				}
				if ($(".MiMa1").val() == "" || $(".MiMa1").val() == MiMa_TiShi) {
					$(".MiMaPanDuan").text("密码不能为空");
					return false;
				}
				if ($(".MiMa2").val() == "" || $(".MiMa2").val() == "重复密码") {
					$(".MiMaPanDuan").text("密码不能为空");
					return false;
				}
				if ($(".MiMa1").val().length < 6 || $(".MiMa2").val().length < 6) {
					$(".MiMaPanDuan").text("密码至少6位数");
				}
				if (pwd_1 == pwd_2) {
					Pwd = pwd_1;
				} else {
					$(".MiMaPanDuan").text("两次密码不相同");
					return false;
				}
			}
		})
    </script>
</body>
</html>
